vector object
The vector object is used to store a set of coordinates for a 2d or 3d environment.
vector(float x, float y, float z)
Parameters:
x
An optional float representing the x value of the vector.
y
A float representing the y value of the vector. This parameter must be filled in if an x value is specified.
z
An optional float representing the z value of the vector.
Remarks:
The parameters may simply be left out if desired. This will simply give values of 0 to all the coordinates.
This object contains the following overloaded operators:
- == and != (compares two vectors)
- =, +=, +, -=, - (uses arithmetic to add and subtract vectors to and from other vectors)
- *=, /=, *, / (multiplies/divides a vector by a scale value, represented by a float)
Example:
// Create a vector object and display its values.
void main()
{
vector game_world(5, 2, 3);
alert("Information", "Current coordinates are "+game_world.x+", "+game_world.y+", "+game_world.z+".");
}